<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <h1>vue2-深层响应式</h1>
    <p>message: {{ message }}</p>
    <button @click="fn">btn</button>
    <p>arr: {{ arr }}</p>
    <p>obj: {{ obj }}</p>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

  <script>
    var app = new Vue({
      el: '#app',
      data() {
        return {
          message: 'Hello Vue!',
          arr: [1,2,3],
          obj: {
            a: 3,
            b: 4
          }
        }
      },
      methods: {
        fn() {
          this.arr[1] = 20;
          this.arr = [...this.arr];
          console.log(this.arr);
        }
      }
    })
    </script>
</body>
</html>